<template>
    <div id='btnsBox'>
        <button @click="handleClick(scope.row)" type="text" size="small" v-if="getButtonConfig&&getButtonConfig.edit">{{scope.row.status=='已发布'?'查看':'修改'}}</button>
        <button type="text" size="small" @click="setOnTop(scope.row)" :disabled="scope.row.status=='草稿'" v-if="getButtonConfig&&getButtonConfig.top">{{scope.row.onTop=='不置顶'?'置顶':'取消置顶'}}</button>
        <button type="text" size="small" @click="deleteRow(scope.row,scope.$index)" v-if="getButtonConfig&&getButtonConfig.delete">删除</button>
    </div>
</template>
<script>
    import {changeOnTop,deleteArticle} from 'api/webArticle';
    export default {
        props:['scope'],
        data(){
            return{

            }
        },
        computed:{
            getButtonConfig(){
                return this.$store.getters.getButtonConfig('webArticleList')
            }
        },
        methods:{
            handleClick(row) {
                this.$router.push({name:'reviseArticle',query:{'id':row.id,'uuid':row.uuid}})
                // console.log(row);
            },
            setOnTop(row){
                //  置顶
                changeOnTop(row.uuid)
                  .then((response)=>{
                    let data=response.data;
                    this.$emit('updateView');
                  })
            },
            deleteRow(row,index){
                this.$confirm('您确定要删除吗?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    // 删除文章
                    deleteArticle(row.uuid)
                    .then((response)=>{
                        let data=response.data;
                        if(data.resultCode=='200'){
                            this.$emit('updateView');
                            this.$message({
                                type: 'success',
                                message: '删除成功!'
                            });
                        }
                    })
                })
            }
        }
    }
</script>
<style lang="less" scoped>
    #btnsBox{
        text-align: left;
        button{
            background-color: transparent;
            color:#63c5ce;
            font-size: 14px;
            padding:0 10px;
            border-right: 1px solid #63c5ce;
            border-radius:0; 
            cursor: pointer;
            &:last-child{
                border:none;
            }
            &:disabled{
                color:#bbb;
                cursor:not-allowed;
            }
        }
        .fontColorGary{
            color: #bbb;
        }
    }
</style>

